ABC137 C - Green Bin
提出
code: python
n = int(input())
strings = set()
anagrams = {}
for i in s:
sortedString = ''.join(sorted(i))
if (sortedString in strings):
try:
except KeyError:
else:
strings.add(sortedString)
ans = 0
for i in anagrams.values():
ans += (i * (i+1)) // 2
print(ans)
メモ
TLE
code: python
n = int(input())
sortedS = []
for i in s:
sortedS.append(''.join(sorted(i)))
setS = set(sortedS)
ans = 0
for i in setS:
anagramCounts = sortedS.count(i)
ans += (anagramCounts * (anagramCounts - 1)) // 2
print(ans)